<?php
/**************************************************************************************************
|
| AudioShare - Audio Sharing Script
| http://www.audiosharescript.com
| webmaster@audiosharescript.com
|
|**************************************************************************************************
|
| By using this software you agree that you have read and acknowledged our End-User License 
| Agreement available at http://www.audiosharescript.com/eula.html and to be bound by it.
|
| Copyright (c) 2010 AudioShareScript.com. All rights reserved.
|**************************************************************************************************/

include("include/config.php");
include("include/functions/import.php");
$thebaseurl = $config['baseurl'];

if ($_SESSION[USERID] != "" && $_SESSION[USERID] >= 0 && is_numeric($_SESSION[USERID]))
{
	$messageid = htmlentities(intval($_REQUEST[messageid]));
	$messageid = escape($messageid);
	
	if (is_numeric($messageid))
	{
		$query = "SELECT A.*, B.username from messages_inbox A, members B where A.MID='".mysql_real_escape_string($messageid)."' AND A.MSGFROM=B.USERID order by A.MID desc limit 1";
		$executequery = $conn->Execute($query);
		$msgarray = $executequery->getarray();
		STemplate::assign('msgarray',$msgarray);

		if (count($msgarray) < 1)
		{
			$error = "$lang[694]";
		}
		else
		{
			$query = "UPDATE messages_inbox SET unread='0' WHERE MID='".mysql_real_escape_string($messageid)."'";
			$executequery = $conn->Execute($query);
		}
	
	}
	else
	{
		$error = "$lang[695]";
	}


}
else
{
	header("Location:$config[baseurl]/login.php");exit;
}

STemplate::assign('pagetitle',"$lang[483]");

//TEMPLATES BEGIN
STemplate::assign('error',$error);
STemplate::assign('message',$message);
STemplate::display('header.tpl');
STemplate::display('viewmessage.tpl');
STemplate::display('footer.tpl');
//TEMPLATES END
?>